def is_number(s):
    """检查字符串是否为数字"""
    try:
        float(s)
        return True
    except ValueError:
        return False

def valid_operator(op):
    """检查运算符是否有效"""
    return op in ['+', '-', '*', '/']

def calculate(num1, operator, num2):
    """执行计算"""
    if not (is_number(num1) and is_number(num2)):
        return "错误：请输入有效的数字"

    num1 = float(num1)
    num2 = float(num2)

    if operator == '+':
        return num1 + num2
    elif operator == '-':
        return num1 - num2
    elif operator == '*':
        return num1 * num2
    elif operator == '/':
        if num2 == 0:
            return "错误：除数不能为零"
        else:
            return num1 / num2
    else:
        return "错误：无效的运算符"

def calculator():
    num1 = input("输入第一个数字: ")
    operator = input("输入运算符 (+, -, *, /): ")
    num2 = input("输入第二个数字: ")

    result = calculate(num1, operator, num2)
    print(result)

# 运行计算器
calculator()
